<% layout('/layouts/default.html', {title: '入库单管理', libs: ['validate','fileupload']}){ %>
<div class="main-content">
	<div class="box box-main">
		<div class="box-header with-border">
			<div class="box-title">
				<i class="fa icon-note"></i> ${text(inboundOrder.isNewRecord ? '新增入库单' : '编辑入库单')}
			</div>
			<div class="box-tools pull-right">
				<button type="button" class="btn btn-box-tool" data-widget="collapse"><i class="fa fa-minus"></i></button>
			</div>
		</div>
		<#form:form id="inputForm" model="${inboundOrder}" action="${ctx}/logistics/inboundorder/inboundOrder/save" method="post" class="form-horizontal">
			<div class="box-body">
				<div class="form-unit">${text('基本信息')}</div>
				<#form:hidden path="inboundOrderId"/>
				<#form:hidden path="outboundOrderId"/>
				<div class="row">
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required hide">*</span> ${text('单据编号')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
								<#form:input path="inboundOrderCode" readonly="true" placeholder="自动生成" maxlength="100" class="form-control"/>
							</div>
						</div>
					</div>
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required ">*</span> ${text('服务订单')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
                                <#form:select path="serviceOrderId" items="${listServiceOrder}" id="serviceOrderId"
                                itemLabel="serviceOrderCode" itemValue="serviceOrderId" blankOption="true" class="form-control" readonly="true"/>
							</div>
						</div>
					</div>
				</div>
                <div class="form-unit">${text('仓库信息')}</div>
				<div class="row">
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required ">*</span> ${text('车架号')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
								<#form:input path="frameNumber" maxlength="100" class="form-control required" readonly="true"/>
							</div>
						</div>
					</div>
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required hide">*</span> ${text('车辆名称')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
                                <#form:select path="carId" items="${listCar}"
                                itemLabel="carName" itemValue="carId" blankOption="true" class="form-control" readonly="true"/>
							</div>
						</div>
					</div>
				</div>
				<div class="row">
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required ">*</span> ${text('仓库类型')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
								<#form:select path="toWarehouseType" id="toWarehouseType" dictType="warehouse_xingzhi" blankOption="true" class="form-control required" readonly="true"/>
							</div>
						</div>
					</div>
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required ">*</span> ${text('仓库名称')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
                                <!--<#form:select path="toWarehouse" id="toWarehouse"  readonly="true"
                                itemLabel="warehouseName" itemValue="warehouseId" blankOption="true" class="form-control required"/>-->

                                <#form:select path="toWarehouse" items="${listWarehouse}" readonly="true"
                                itemLabel="warehouseName" itemValue="warehouseId" blankOption="true" class="form-control" />
                            </div>
						</div>
					</div>
				</div>
				<div class="row">
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required ">*</span> ${text('入库时间')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
								<#form:input path="date" readonly="true" maxlength="20" class="form-control laydate required"
									dataFormat="date" data-type="date" data-format="yyyy-MM-dd"/>
							</div>
						</div>
					</div>
				</div>
				<div class="row">
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required hide">*</span> ${text('原仓库')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
                                <#form:select path="fromWarehouse" items="${listWarehouse}" id="fromWarehouse"
                                itemLabel="warehouseName" itemValue="warehouseId" blankOption="true" class="form-control" readonly="true"/>
							</div>
						</div>
					</div>
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required hide">*</span> ${text('原库出库时间')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
                                <#form:hidden path="outboundDate" maxlength="20" class="form-control laydate"
                                dataFormat="date" data-type="date" data-format="yyyy-MM-dd"/>

                                <#form:input path="outboundDate" readonly="true" maxlength="20" class="form-control laydate"
									dataFormat="date" data-type="date" data-format="yyyy-MM-dd" disabled="true"/>
							</div>
						</div>
					</div>
				</div>
				<div class="row">
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required hide">*</span> ${text('原库仓类型')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
								<#form:select path="fromWarehouseType" dictType="warehouse_xingzhi" blankOption="true" class="form-control" readonly="true"/>
							</div>
						</div>
					</div>
				</div>
				<!--<div class="row">
					<div class="col-xs-12">
						<div class="form-group">
							<label class="control-label col-sm-2" title="">
								<span class="required hide">*</span> ${text('备注信息')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-10">
								<#form:textarea path="remarks" rows="4" maxlength="500" class="form-control"/>
							</div>
						</div>
					</div>
				</div>-->
                <div class="form-unit">${text('附件信息')}</div>
				<div class="row">
					<div class="col-xs-12">
						<div class="form-group">
							<label class="control-label col-sm-2">
								<span class="required hide">*</span> ${text('附件上传')}：</label>
							<div class="col-sm-10">
								<#form:fileupload id="uploadFile" bizKey="${inboundOrder.id}" bizType="inboundOrder_file"
									uploadType="all" class="" readonly="false" preview="true"/>
							</div>
						</div>
					</div>
				</div>
                <div class="form-unit">${text('系统信息')}</div>
                <div class="row">
                    <div class="col-xs-6">
                        <div class="form-group">
                            <label class="control-label col-sm-4" title="">
                                <span class="required hide">*</span> ${text('创建日期')}：<i class="fa icon-question hide"></i></label>
                            <div class="col-sm-8">
                                <#form:input path="createDate" class="form-control" disabled="true"
                                dataFormat="datetime2" data-type="datetime" data-format="yyyy-MM-dd HH:mm:ss"/>
                            </div>
                        </div>
                    </div>
                    <div class="col-xs-6">
                        <div class="form-group">
                            <label class="control-label col-sm-4" title="">
                                <span class="required hide">*</span> ${text('创建人')}：<i class="fa icon-question hide"></i></label>
                            <div class="col-sm-8">
                                <#form:input path="createBy" class="form-control" disabled="true"/>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="row">
                    <div class="col-xs-6">
                        <div class="form-group">
                            <label class="control-label col-sm-4" title="">
                                <span class="required hide">*</span> ${text('最后修改日期')}：<i class="fa icon-question hide"></i></label>
                            <div class="col-sm-8">
                                <#form:input path="updateDate" readonly="true" maxlength="20" class="form-control"
                                dataFormat="datetime2" data-type="datetime" data-format="yyyy-MM-dd HH:mm:ss"/>
                            </div>
                        </div>
                    </div>
                    <div class="col-xs-6">
                        <div class="form-group">
                            <label class="control-label col-sm-4" title="">
                                <span class="required hide">*</span> ${text('最后修改人')}：<i class="fa icon-question hide"></i></label>
                            <div class="col-sm-8">
                                <#form:input path="updateBy" readonly="true" maxlength="20" class="form-control"/>
                            </div>
                        </div>
                    </div>
                </div>
			</div>
			<div class="box-footer">
				<div class="row">
					<div class="col-sm-offset-2 col-sm-10">
						<% if (hasPermi('logistics:inboundorder:inboundOrder:edit')){ %>
							<button type="submit" class="btn btn-sm btn-primary" id="btnSubmit"><i class="fa fa-check"></i> ${text('保 存')}</button>&nbsp;
						<% } %>
						<button type="button" class="btn btn-sm btn-default" id="btnCancel" onclick="js.closeCurrentTabPage()"><i class="fa fa-reply-all"></i> ${text('关 闭')}</button>
					</div>
				</div>
			</div>
		</#form:form>
	</div>
</div>
<% } %>
<script>
$("#inputForm").validate({
	submitHandler: function(form){
		js.ajaxSubmitForm($(form), function(data){
			js.showMessage(data.message);
			if(data.result == Global.TRUE){
				js.closeCurrentTabPage(function(contentWindow){
					contentWindow.page();
				});
			}
		}, "json");
    }
});

$("#toWarehouseType").change(function () {
    if ($(this).val()){
        $.ajax({
            type : "post",
            async : false,
            url : "${ctx}/base/warehouse/twarehouse/listData",
            data : {
                'property' : $("#toWarehouseType").val()
            },
            dataType : "json",
            success : function(result) {
                js.log(result)
                var list = result.list;
                $("#toWarehouse").empty();
                for (var i = 0; i < list.length; i++) {
                    var warehouseId = list[i].id;
                    var warehouseName = list[i].warehouseName;
                    var option = $("<option>").attr({"value" : warehouseId}).text(warehouseName);
                    $("#toWarehouse").append(option);
                }
                $("#toWarehouse option:first").prop("selected", 'selected');
                $("#toWarehouse").change();
            },
            error : function(json) {
                $.jBox.alert("网络异常！");
            }
        });
    }else {
        $("#toWarehouse").empty();
    }
});


</script>